package com.dragon.connector.imServer.startup;

import cn.hutool.extra.spring.SpringUtil;
import com.dragon.connector.imServer.session.service.SessionManger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Import;

@Import(SpringUtil.class)
@SpringBootApplication(scanBasePackages = "com.dragon")
public class ConnectorApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {

        // 启动并初始化 Spring 环境及其各 Spring 组件
        ApplicationContext context =
                SpringApplication.run(ConnectorApplication.class,args);
        /**
         * 将SessionManger 单例设置为spring bean
         */
        SessionManger sessionManger = context.getBean(SessionManger.class);
        SessionManger.setSingleInstance(sessionManger);
    }

}
